home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / ScreenSavers / BackSpaceViews / LifeView.BackModule / LifeView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-12  |  3.0 KB  |  119 lines

  1. #import <appkit/View.h>
  2. #import "Thinker.h"
  3.  
  4. #define ITERATIONS 20000/* max # of iterations before restarting */
  5. #define PANELTIME 333   /* ms delay between *panel* animation frames */
  6. #define DEEPEDGE 2      /* edge is this # squares beyond visible */
  7. #define MINCELLSIZE 2   /* Make sure cell size gets no smaller than... */
  8. #define MAXCELLSIZE 24  /* Make sure cell size gets no bigger than... */
  9. #define MINCLUSTERS 1   /* Make sure # of clusters gets no smaller than... */
  10. #define MAXCLUSTERS 4   /* Make sure # of clusters gets no bigger than... */
  11. #define MINDELAY 0      /* Minimum lower-bound frame delay, in ms */
  12. #define MAXDELAY 10000  /* Maximum lower-bound frame delay, in ms */
  13. #define COLORS 24       /* Generations from youngest color to oldest color */
  14. #define SQUAREBLOCK 32  /* Number of squares of one color to draw at once */
  15. #define STATSIZE 1024   /* Recognizes all stasis periods up to this number */
  16. #define STATIVAL 128    /* Takes up to this long to recognize stasis */
  17. #ifdef DEEPEDGE
  18. #  define MAXCOLS (1600/MINCELLSIZE+2+2*DEEPEDGE)
  19. #  define MAXROWS (1280/MINCELLSIZE+2+2*DEEPEDGE)
  20. #else
  21. #  define MAXCOLS (1600/MINCELLSIZE+2) /* full screen of smallest cells (x) */
  22. #  define MAXROWS (1280/MINCELLSIZE+2) /* (y) */
  23. #endif
  24.  
  25. typedef struct _lifecell {
  26.     int next;
  27.     char neighbors;
  28.     char color;
  29. } lifecell;
  30.  
  31. @interface LifeView:View
  32. {
  33.     lifecell *Grid;
  34.     
  35.     int ifirst;
  36.     int ncols, nrows;
  37.     int countDown;
  38.     int running;
  39.     int cellSize;
  40.     int clusters;
  41.     int xoffset, yoffset;
  42.     BStimeval lasttime;
  43.  
  44.     NXColor youngColor;
  45.     NXColor mediumColor;
  46.     NXColor oldColor;
  47.     int delay;
  48.  
  49.     NXColor colorTable[COLORS];
  50.     int squareCount[COLORS];
  51.     NXRect squareBuffer[COLORS][SQUAREBLOCK];
  52.     
  53.     int stasis[STATSIZE];
  54.     int strack;
  55.     int spass;
  56.     int sindex;
  57.  
  58.     id sharedInspectorPanel;
  59.     id panelYoungColorWell;
  60.     id panelMediumColorWell;
  61.     id panelOldColorWell;
  62.     id panelRestartButton;
  63.     id panelStepButton;
  64.     id panelLifeView;
  65.     id panelCreditsView;
  66.     id panelSizeMatrix;
  67.     id panelRHSizeButton;
  68. }
  69.  
  70. - oneStep;
  71. - drawSquares;
  72. - putSquare:(int)x :(int)y Color:(int)color;
  73. - flushColor:(int)color;
  74. - flushSquares;
  75. - drawSelf:(const NXRect *)rects :(int)rectCount;
  76. - (const char *) windowTitle;
  77. - setupSquareBuffer;
  78. - initFrame:(const NXRect *)frameRect;
  79. - free;
  80. - getLifeDefaults;
  81. - sizeTo:(NXCoord)width :(NXCoord)height;
  82. - initLife;
  83. - clearLife;
  84. - checkStasis:(int)checksum;
  85.  
  86. - computeColors;
  87. - updateViews;
  88.  
  89. - inspector:sender;
  90. - inspectorInstalled;
  91. - takeYoungColorFrom:sender;
  92. - takeMediumColorFrom:sender;
  93. - takeOldColorFrom:sender;
  94. - doSizeMatrix:sender;
  95. - animateSingleStep:sender;
  96. - doSingleStep:sender;
  97. - doRestart:sender;
  98.  
  99. - doRHSizeButton:sender;
  100. - showRHSizeButton:sender;
  101. - hideRHSizeButton:sender;
  102.  
  103. - showCredits:sender;
  104. - hideCredits:sender;
  105.  
  106. - doShowCredits:sender;
  107. - doHideCredits:sender;
  108.  
  109. @end
  110.  
  111. @interface StaticLifeView:LifeView
  112. {
  113. }
  114. - setYoungColor:(NXColor)yc MediumColor:(NXColor)mc OldColor:(NXColor)oc;
  115. - setLifeCellSize:(int)cs;
  116.  
  117. @end
  118.  
  119.